//
//  ProductTypeCollectionViewCell.swift
//  Nahuo
//
//  Created by zang qilong on 2017/5/20.
//  Copyright © 2017年 zang qilong. All rights reserved.
//

import UIKit

class ProductTypeCollectionViewCell: UICollectionViewCell {
    @IBOutlet weak var productImageView: UIImageView!
    @IBOutlet weak var playButton: UIButton!
    @IBOutlet weak var productDiscountLabel: UILabel!
    @IBOutlet weak var productOrignalLabel: UILabel!
    @IBOutlet weak var productNameLabel: UILabel!
    @IBOutlet weak var favouriteButton: UIButton!
    @IBOutlet weak var resellButton: UIButton!
    var videoURL:URL?

    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }
    
    
    func setupCellWithProductModel(model:Product) {
        productNameLabel.text = model.name
        productOrignalLabel.text = "¥\(model.retailPrice!)"
        productDiscountLabel.text = "¥\(model.tradePrice!)"
        
        if let imgsURLArray = model.imgs,let firstStringURL = imgsURLArray.first {
            productImageView.yy_setImage(with: URL(string: firstStringURL), options: .progressiveBlur)
        }
        
        if let videosURLArray = model.videos, let firstVideoURL = videosURLArray.first {
            videoURL = URL(string: firstVideoURL)
            playButton.isHidden = false
        }else {
            playButton.isHidden = true
        }
        
    }

}
